home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / PInterfaces / Serial.p < prev    next >
Text File  |  1996-05-01  |  6KB  |  170 lines

  1. {
  2.      File:        Serial.p
  3.  
  4.      Contains:    Asynchronous Serial Driver (.AIn/.AOut/.BIn/.BOut) Interfaces
  5.  
  6.      Version:    Technology:    System 7.5.2
  7.                  Release:    Universal Interfaces 3.0d3 on Copland DR1
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        If you find a problem with this file, send the file and version
  12.                  information (from above) and the problem description to:
  13.  
  14.                      Internet:    apple.bugs@applelink.apple.com
  15.                      AppleLink:    APPLE.BUGS
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT Serial;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __SERIAL__}
  28. {$SETC __SERIAL__ := 1}
  29.  
  30. {$I+}
  31. {$SETC SerialIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37.  
  38. {$PUSH}
  39. {$ALIGN MAC68K}
  40. {$LibExport+}
  41.  
  42.  
  43. CONST
  44.     baud150                        = 763;
  45.     baud300                        = 380;
  46.     baud600                        = 189;
  47.     baud1200                    = 94;
  48.     baud1800                    = 62;
  49.     baud2400                    = 46;
  50.     baud3600                    = 30;
  51.     baud4800                    = 22;
  52.     baud7200                    = 14;
  53.     baud9600                    = 10;
  54.     baud14400                    = 6;
  55.     baud19200                    = 4;
  56.     baud28800                    = 2;
  57.     baud38400                    = 1;
  58.     baud57600                    = 0;
  59.     stop10                        = 16384;
  60.     stop15                        = -32768;
  61.     stop20                        = -16384;
  62.     noParity                    = 0;
  63.     oddParity                    = 4096;
  64.     evenParity                    = 12288;
  65.     data5                        = 0;
  66.     data6                        = 2048;
  67.     data7                        = 1024;
  68.     data8                        = 3072;
  69.  
  70.     aData                        = 6;                            {  channel A data in or out (historical)  }
  71.     aCtl                        = 2;                            {  channel A control (historical)  }
  72.     bData                        = 4;                            {  channel B data in or out (historical)  }
  73.     bCtl                        = 0;                            {  channel B control (historical)  }
  74.     ctsEvent                    = 32;                            {  flag for SerShk.errs and SerShk.evts  }
  75.     breakEvent                    = 128;                            {  flag for SerShk.errs and SerShk.evts  }
  76.     xOffWasSent                    = 128;                            {  flag for SerStaRec.xOffSent  }
  77.     dtrNegated                    = 64;                            {  flag for SerStaRec.xOffSent  }
  78.     ainRefNum                    = -6;                            {  serial port A input  }
  79.     aoutRefNum                    = -7;                            {  serial port A output  }
  80.     binRefNum                    = -8;                            {  serial port B input  }
  81.     boutRefNum                    = -9;                            {  serial port B output  }
  82.     swOverrunErr                = 1;                            {  serial driver error masks  }
  83.     breakErr                    = 8;                            {  serial driver error masks  }
  84.     parityErr                    = 16;                            {  serial driver error masks  }
  85.     hwOverrunErr                = 32;                            {  serial driver error masks  }
  86.     framingErr                    = 64;                            {  serial driver error masks  }
  87.     kOptionClockX1CTS            = 64;                            {  option bit used with Control code 16  }
  88.     kOptionPreserveDTR            = 128;                            {  option bit used with Control code 16  }
  89.  
  90.     sPortA                        = 0;
  91.     sPortB                        = 1;
  92.  
  93.  
  94. TYPE
  95.     SPortSel                            = SInt8;
  96. {  csCodes for serial driver Control routines  }
  97.  
  98. CONST
  99.     kSERDConfiguration            = 8;                            {  program port speed, bits/char, parity, and stop bits  }
  100.     kSERDInputBuffer            = 9;                            {  set buffer for chars received with no read pending  }
  101.     kSERDSerHShake                = 10;                            {  equivalent to SerHShake, largely obsolete  }
  102.     kSERDClearBreak                = 11;                            {  assert break signal on output  }
  103.     kSERDSetBreak                = 12;                            {  negate break state on output  }
  104.     kSERDBaudRate                = 13;                            {  set explicit baud rate, other settings unchanged  }
  105.     kSERDHandshake                = 14;                            {  superset of 10, honors setting of fDTR  }
  106.     kSERDClockMIDI                = 15;                            {  clock externally on CTS with specified multiplier  }
  107.     kSERDMiscOptions            = 16;                            {  select clock source and DTR behavior on close  }
  108.     kSERDAssertDTR                = 17;                            {  assert DTR output  }
  109.     kSERDNegateDTR                = 18;                            {  negate DTR output  }
  110.     kSERDSetPEChar                = 19;                            {  select char to replace chars with invalid parity  }
  111.     kSERDSetPEAltChar            = 20;                            {  select char to replace char that replaces chars with invalid parity  }
  112.     kSERDSetXOffFlag            = 21;                            {  set XOff output flow control (same as receiving XOff)  }
  113.     kSERDClearXOffFlag            = 22;                            {  clear XOff output flow control (same as receiving XOn)  }
  114.     kSERDSendXOn                = 23;                            {  send XOn if input flow control state is XOff  }
  115.     kSERDSendXOnOut                = 24;                            {  send XOn regardless of input flow control state  }
  116.     kSERDSendXOff                = 25;                            {  send XOff if input flow control state is XOn  }
  117.     kSERDSendXOffOut            = 26;                            {  send XOff regardless of input flow control state  }
  118.     kSERDResetChannel            = 27;                            {  reset serial I/O channel hardware  }
  119.     kSERD115KBaud                = 115;                            {  set 115.2K baud data rate (some driver versions)  }
  120.     kSERD230KBaud                = 230;                            {  set 230.4K baud data rate (some driver versions)  }
  121.  
  122. {  csCodes for serial driver Status routines  }
  123.     kSERDInputCount                = 2;                            {  return characters available (SerGetBuf)  }
  124.     kSERDStatus                    = 8;                            {  return characters available (SerStatus)  }
  125.     kSERDVersion                = 9;                            {  return version number in first byte of csParam  }
  126.  
  127.  
  128. TYPE
  129.     SerShkPtr = ^SerShk;
  130.     SerShk = PACKED RECORD
  131.         fXOn:                    Byte;                                    {  XOn flow control enabled flag  }
  132.         fCTS:                    Byte;                                    {  CTS flow control enabled flag  }
  133.         xOn:                    UInt8;                                    {  XOn character  }
  134.         xOff:                    UInt8;                                    {  XOff character  }
  135.         errs:                    Byte;                                    {  errors mask bits  }
  136.         evts:                    Byte;                                    {  event enable mask bits  }
  137.         fInX:                    Byte;                                    {  Input flow control enabled flag  }
  138.         fDTR:                    Byte;                                    {  DTR input flow control flag  }
  139.     END;
  140.  
  141.     SerStaRecPtr = ^SerStaRec;
  142.     SerStaRec = PACKED RECORD
  143.         cumErrs:                Byte;                                    {  errors accumulated since last SerStatus() call  }
  144.         xOffSent:                Byte;                                    {  input (requested to be) held off by xOffWasSent or dtrNegated  }
  145.         rdPend:                    Byte;                                    {  incomplete read pending in I/O queue  }
  146.         wrPend:                    Byte;                                    {  incomplete write pending in I/O queue  }
  147.         ctsHold:                Byte;                                    {  transmit disabled by hardware handshaking  }
  148.         xOffHold:                Byte;                                    {  transmit disabled by XOn/XOff handshaking  }
  149.     END;
  150.  
  151. {$IFC FOR_SYSTEM7_ONLY }
  152. FUNCTION SerReset(refNum: INTEGER; serConfig: INTEGER): OSErr;
  153. FUNCTION SerSetBuf(refNum: INTEGER; serBPtr: Ptr; serBLen: INTEGER): OSErr;
  154. FUNCTION SerHShake(refNum: INTEGER; {CONST}VAR flags: SerShk): OSErr;
  155. FUNCTION SerSetBrk(refNum: INTEGER): OSErr;
  156. FUNCTION SerClrBrk(refNum: INTEGER): OSErr;
  157. FUNCTION SerGetBuf(refNum: INTEGER; VAR count: LONGINT): OSErr;
  158. FUNCTION SerStatus(refNum: INTEGER; VAR serSta: SerStaRec): OSErr;
  159. {$ENDC}
  160. {$ALIGN RESET}
  161. {$POP}
  162.  
  163. {$SETC UsingIncludes := SerialIncludes}
  164.  
  165. {$ENDC} {__SERIAL__}
  166.  
  167. {$IFC NOT UsingIncludes}
  168.  END.
  169. {$ENDC}
  170.